import logging, email
from google.appengine.ext import webapp
from google.appengine.ext.webapp.mail_handlers import InboundMailHandler
from google.appengine.ext.webapp.util import run_wsgi_app

class ReceiveEmail(InboundMailHandler):
	def receive(self,message):
                logging.info("Received email from %s" % message.sender)
                plaintext = message.bodies(content_type='text/plain')
                for text in plaintext:
                        txtmsg = ""
                        txtmsg = text[1].decode()
                        logging.info("Body is %s" % txtmsg)
                        
application = webapp.WSGIApplication([
  ReceiveEmail.mapping()
], debug=True)
def main():
  run_wsgi_app(application)
if __name__ == "__main__":
  main()